package com.reremouse.rerebbs.dao.impl;

import com.reremouse.model.PartnerModel;
import com.reremouse.rerebbs.dao.IPartnerDAO;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.io.Serializable;
import java.util.List;

public class PartnerDAO
        implements IPartnerDAO, Serializable {
    @PersistenceContext
    private EntityManager entityManager;

    public EntityManager getEntityManager() {
        return this.entityManager;
    }

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    public List<PartnerModel> findAllPartnerModel() {
        String q = "select yis from PartnerModel yis order by yis.ord";
        List<PartnerModel> ps = this.entityManager.createQuery(q).getResultList();
        return ps;
    }

    public List<PartnerModel> findPartnerModelByType(long id) {
        String q = "select yis from PartnerModel yis where yis.typeId=" + id + " order by yis.ord";
        List<PartnerModel> ps = this.entityManager.createQuery(q).getResultList();
        return ps;
    }

    public PartnerModel findPartnerModel(long id) {
        PartnerModel p = (PartnerModel) this.entityManager.find(PartnerModel.class, Long.valueOf(id));
        return p;
    }

    public void updatePartnerModel(PartnerModel partnerModel) {
        this.entityManager.merge(partnerModel);
    }

    public void deletePartnerModel(long id) {
        PartnerModel yp = (PartnerModel) this.entityManager.find(PartnerModel.class, Long.valueOf(id));
        this.entityManager.remove(yp);
    }

    public void addPartnerModel(PartnerModel partnerModel) {
        this.entityManager.persist(partnerModel);
    }
}



/* Location:           F:\jsp源码\蝙蝠论坛系统\rerebbs\WEB-INF\classes\

 * Qualified Name:     com.reremouse.rerebbs.dao.impl.PartnerDAO

 * JD-Core Version:    0.7.0.1

 */